//
//  AuthoritySettingCellTopView.m
//  YSSmartHome
//
//  Created by yanghao on 25/05/2017.
//  Copyright © 2017 yahaong. All rights reserved.
//

#import "AuthoritySettingCellTopView.h"
#import "YSCommon.h"
#import "ZTDevice.h"
#import "MQTTSessionManager.h"


@interface AuthoritySettingCellTopView ()
@property (nullable, nonatomic, strong) UIView* leftRedView;
@property (nullable, nonatomic, strong) UILabel* titleLable;

@end
@implementation AuthoritySettingCellTopView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self initSubviews];
    }
    return self;
}
- (void)initSubviews
{
    self.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.leftRedView];
    [self addSubview:self.titleLable];
    [self layoutPageSubviews];
}


- (void)layoutPageSubviews
{
    [self.leftRedView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self);
        make.width.equalTo(kIphoneSize_Widith(5));
        make.height.equalTo(kIphoneSize_Widith(20));
        make.centerY.equalTo(self);
    }];
    [self.titleLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.leading.equalTo(self.leftRedView.trailing).offset(kIphoneSize_Widith(20));
    }];
}

#pragma mark - getters and setters 

- (void)setTitle:(NSString *)title
{
    self.titleLable.text = title;
}
- (UIView *)leftRedView
{
    if (!_leftRedView) {
        _leftRedView = [[UIView alloc]init];
        _leftRedView.backgroundColor = RGBColor(239, 75, 58);
    }
    return _leftRedView;
}
- (UILabel *)titleLable
{
    if (!_titleLable) {
        _titleLable = [[UILabel alloc]init];
        _titleLable.textColor = RGBColor(51, 51, 51);
    }
    return _titleLable;
}
@end
